package com.tsu.mall.order.mapper;

import com.tsu.mall.order.entity.MemberAddress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tttttt
 * @since 2023-04-07
 */
public interface MemberAddressMapper extends BaseMapper<MemberAddress> {

    @Select("select * from member_address where member_id=#{id}")
    List<MemberAddress> selectMemberAddressByCurrentMemberId(Integer id);

    @Select("select * from member_address where id=#{addressId}")
    MemberAddress selectMemberAddressByAddressId(Integer addressId);

    @Update("update member_address set default_address='是' where id=#{addressId}")
    void updateMemberAddressByAddressId(Integer addressId);
    @Update("update member_address set default_address='否' where id<>#{addressId}")
    void updateMemberAddress(Integer addressId);
}
